<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 动态注册
// Route::rule('路由表达式','路由地址','请求类型','路由参数（数组）','变量规则（数组）');
/*
    路由表达式:URL访问规则（包括静态规则和动态规则）,只有符合规则的路由才能正确访问;
    路由地址:实际访问的地址（可以是控制器操作、类的方法或者闭包）;
    请求类型:表示当前路由生效使用的请求类型,包括GET/POST/PUT/DELETE等,如果希望任何请求都能访问使用*号（默认值）。
    路由参数:路由匹配的条件约束或设置参数（用于检测或者解析）;
    路由变量:路由规则里面的动态变量以及PATH_INFO里面的参数都称之为路由变量;
    变量规则:路由规则中的变量的匹配规则（正则表达式）;

    支持任意请求规则
    Route::rule('new/:id','News/update');
    定义GET请求路由规则
    Route::get('new/:id','News/read');
    定义POST请求路由规则
    Route::post('new/:id','News/update');
    定义PUT请求路由规则
    Route::put('new/:id','News/update');
    定义DELETE请求路由规则
    Route::delete('new/:id','News/delete');
    所有请求都支持的路由规则
    Route::gupnp_service_proxy_add_notify(proxy, value, type, callback)('new/:id','News/read');
*/

use think\Route;
// get


Route::get('/', 'index/index/index');
Route::get('home', 'index/index/index');
// post
Route::post('ppp', 'index/index/ppp');
// GET/POST
Route::rule('ooxx','index/index/index');
// 任意请求
Route::any('xxoo','index/index/index');

Route::get('admin/user/index', 'admin/user/index');
Route::get('admin/user/insert', 'admin/user/insert');
Route::get('admin/user/delete', 'admin/user/delete');
Route::get('admin/user/update', 'admin/user/update');


// 静态路由
//Route::get('user', 'index/index/user');
// 动态路由
// 必传参数
//Route::get('user/:id', 'index/index/user');
// 可选参数
//Route::get('user/[:id]', 'index/index/user');
//
Route::get('user/[:id]$', 'index/index/user');


// 闭包路由
Route::get('js/:id', function ($id){
    if ($id > 250) {
        return '我们这里没有这么多技师';
    } else {
        return '您选择的技师号为: ' . $id;
    }
});

// 路由参数
Route::get('userlist', 'admin/user/index', ['ext'=>'html|shtml']);

// http://s84.com/index/blog/index/id/6.html
// http://s84.com/index/blog/read/name/MRWANG.html
// http://s84.com/index/blog/article/year/2018/month/10/day/25.html

// 变量规则  越容易匹配的规则 越往后放
// http://s84.com/blog/2019/10/05.html
Route::get('blog/:year/:month/:day', 'index/blog/article',[], ['year'=>'\d{4}','month'=>'\d{2}','day'=>'\d{2}']);
// http://s84.com/blog/5.html
Route::get('blog/:id', 'index/blog/index',[],['id'=>'\d+']);
// http://s84.com/blog/ss.html
Route::get('blog/:name', 'index/blog/read',[], ['name'=>'\w+']);

//// 路由分组
Route::group('blog',[
    ':year/:month/:day' => [
        'index/blog/article',
        [],
        ['year'=>'\d{4}','month'=>'\d{2}','day'=>'\d{2}']
    ],
    ':id' => [
        'index/blog/index',
        [],
        ['id'=>'\d+']
    ],
    ':name' => [
        'index/blog/read',
        [],
        ['name'=>'\w+']
    ],
]);


// 生成URL
Route::get('url','index/index/url');

// jump
Route::get('jump','admin/index/jump');

Route::get('rd','admin/index/rd');
//
//// 资源路由 会生成七条路由规则


Route::resource('users', 'rest/User');
Route::get('users/show/:id','rest/user/readPage');
Route::get('logins','rest/user/logins');
Route::post('logindo','rest/user/logindo');



// test

Route::resource('test', 'test/index');

Route::get('list','test/index/list');
Route::get('form','test/index/form');

// 用户模块
Route::get('adduser','test/index/user');
Route::get('assignroles','test/index/assignroles');

// 角色模块
Route::get('addroles','test/index/addroles');
Route::get('queryroles','test/index/queryroles');
Route::get('assignper','test/index/assignper');
//角色分配
Route::post('doassignper','test/index/doassignper');
Route::post('doassignroles','test/index/doassignroles');

// 权限模块
Route::get('addpre','test/index/addpre');
Route::get('querypre','test/index/querypre');


// 添加模块
Route::post('doadduser','test/index/doadduser'); // 这里使用了自带的save
Route::post('doaddroles','test/index/doaddroles');
Route::post('doaddpre','test/index/doaddpre');

// 删除模块
Route::get('delRoles/:id','test/index/delRoles');
Route::get('delpre/:id','test/index/delpre');

//节点
Route::get('assignNode/','test/index/assignNode');
Route::get('showRoles/:id','test/index/showRoles');
// 加载页面(对)
Route::get('showNode/','test/index/showNode');



//节点的一些操作
Route::post('addpreajax/','test/index/addpreajax');
Route::post('delpreajax/','test/index/delpreajax');



// 登录
Route::get('logins','test/index/logins');


Route::get('shouye','test/index/shouye');

Route::post('dologins','test/index/dologins');
Route::post('dologins','test/index/dologins');



// 花瓣前台
Route::get('huaban','huaban/index/index');
Route::post('huaban_reg','huaban/index/reg');
Route::post('huaban_login','huaban/index/login');

// 花瓣个人中心
Route::get('huaban_user','huaban/User/index');
Route::get('zhuxiao','huaban/User/zhuxiao');
// 修改头像
Route::post('updateIcon','huaban/User/updateIcon');

Route::get('updateUser','huaban/User/updateUser');











// 静态注册
return [
    '__pattern__' => [
        'name' => '\w+',
    ],
    '[hello]'     => [
        ':id'   => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
        ':name' => ['index/hello', ['method' => 'post']],
    ],

];
